window.onload=function () {
	getallusers();
}

function getallusers() {
	$.ajax({
		url: 'http://172.18.21.150/ToGo/listUserAll',
		type: 'post',
		dataType: 'json',
		success:function (result) {
			var d=result.data;
			if(result.status=='200')
			{
				for(i=0;i<d.length;i++){
					$("table").append('');
						$("table").append('<tr class="pertr"><td>'+d[i].username+'</td><td>'+d[i].password+'</td><td>'+d[i].realname+'</td><td>'+d[i].email+'</td><td>'+d[i].phoneNumber+'</td><td>'+d[i].sex+'</td><td><a href="javascript:void(0)" onclick="deleteuser('+d[i].user_id+')">删除</a></td></tr>');
				}

			}
		}
	});
	
}
function deleteuser(user_id) {
	$.ajax({
		url: 'http://172.18.21.150/ToGo/deleteUser',
		type: 'post',
		dataType: 'json',
		data:{id:user_id},
		success:function (result) {
			var d=result.data;
			if(result.status=='200')
			{
				window.location.reload(true);
			}
		}
	});
	
}

// $(document).ready(function($) {
// 	$('.delete').bind('click', function() {
// 			if(confirm('确认删除？')){
// 				 alert('删除成功!');
// 				 delRow(this);
// 			}
// 		});	
// });

// function delRow(rows)  
// {  
//    	 $(rows).parent("td").parent("tr").remove();  
// } 
